package com.xuexiang.xui_lib.component.textview.marqueen;

import ohos.agp.components.DependentLayout;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.Text;
import ohos.app.Context;

import com.xuexiang.xui_lib.ResourceTable;

/**
 * 复合字幕
 *
 * @author xuexiang
 * @since 2019/1/14 下午10:13
 */
public class ComplexViewMF extends MarqueeFactory<DependentLayout, ComplexItemEntity> {
    private LayoutScatter inflater;

    public ComplexViewMF(Context context) {
        super(context);
        inflater = LayoutScatter.getInstance(context);
    }

    @Override
    public DependentLayout generateMarqueeItemView(ComplexItemEntity data) {
        DependentLayout view = (DependentLayout) inflater.parse(ResourceTable.Layout_marqueen_layout_complex_view,
            null, true);
        ((Text) view.findComponentById(ResourceTable.Id_title)).setText(data.getTitle());
        ((Text) view.findComponentById(ResourceTable.Id_subTitle)).setText(data.getSubTitle());
        ((Text) view.findComponentById(ResourceTable.Id_time)).setText(data.getTime());
        return view;
    }
}